import request from '@/utils/request'

// 获取分类列表
export function getCategoriesList(num=2,index=0,title=null){
    if(title === null)
        return request.get(`/categories?_limit=${num}&_start=${index}`)
    return request.get(`/categories?_limit=${num}&_start=${index}&title_contains=${title}`)
}


// 获取分类数量
export function getCategoriesCount(title){
    return request.get('/categories/count?title_contains='+title)
}



// 获取指定分类
export function getCategorie(id){
    return request.get('/categories/'+id)
}

// 新建分类
export function addCategorie(data){
    return request.post('/categories',data)
}

// 修改分类
export function editCategorie(data){
    return request.put('/categories/'+data.id,data)
}

// 删除分类
export function delCategorie(id){
    return request.delete('/categories/'+id)
}